﻿using UnityEngine;
using System.Collections;

public class MonsterAttackAndDamage : AttackAndDamage {

    private Transform player; // 获得怪物的攻击对象

    void Awake()
    {
        base.Awake();
        player = GameObject.FindGameObjectWithTag(Tags.player).GetComponent<Transform>();
    }

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}

    public void MonAttackEvent()
    {
        float distance = 0;
        if (player)
        {
            distance = Vector3.Distance(player.transform.position, transform.position);
        }
        if (distance < attackDistance && player)
        {
            player.GetComponent<AttackAndDamage>().TakenDamage(normalAttack);
        }
    }
}
